
const checkAndRedirect = () => {
    if (window.location.href.includes('link.zhihu.com')) {
        const link = document.querySelector('a[href][class=button]');
        console.log(link);
        if (link) {
            const targetUrl = link.href;
            if (targetUrl) {
                // 2秒后跳转
                setTimeout(() => {
                    window.location.href = targetUrl;
                }, 2000);
            }
        }
    }
};

const hidePopup = () => {
    const popup = document.querySelector('.Modal-enter-done');
    if (popup) {
        setTimeout(() => {
            popup.style.display = 'none';
        }, 1000);
    }
};

window.addEventListener('load', () => {
    checkAndRedirect();
    hidePopup();
    new MutationObserver(hidePopup).observe(
        document.body,
        { childList: true, subtree: true }
    );
});